

import java.security.InvalidParameterException;
import java.util.Vector;

public class PlayerData {
	
	/*
	 * My Action Data
	 */
	private int tookShots = 0;
	private int roundMissed = 0;
	private int hits = 0;
	private int misses = 0;
	private int myID = -1;
	
	private final int PLAYER_1 = 0;
	private final int PLAYER_2 = 1;
	private final int PLAYER_3 = 2;
	private final int PLAYER_4 = 3;
	private final int PLAYER_5 = 4;
	private final int PLAYER_6 = 5;
	
	
	
	/**
	 * 2-D Array and the representation of data.
	 * 
	 * 			|Player 1|Player 2|Player 3|Player 4|Player 5|Player 6|
	 * FiredOnMe|        |        |        |        |        |        |        
	 * Hits     |        |        |        |        |        |        | 
	 * Misses   |        |        |        |        |        |        |
	 * Small Amo|        |        |        |        |        |        |
	 * Med. Ammo|        |        |        |        |        |        |
	 * Lrg. Ammo|        |        |        |        |        |        |
	 * 
	 */
	private int [][] firedOnBy = new int[6][6];
	
	
	/**
	 * 1-D Array and the representation of data.
	 * 
	 *  |Small Ammo|Medium Ammo|Large Ammo|
	 */
	private int [] ammoUsed = new int[3];
	
	public PlayerData(){
		
	}
	
	public void setMyID(int player){
		myID = player;
	}
	
	public void addHit(){
		hits++;
	}
	
	public void addShot(){
		tookShots++;
	}
	
	public void addMiss(){
		misses++;
	}
	
	public void addMissedRound(){
		roundMissed++;
	}
	
	public void addPlayerHit(int player){
		if(player >= 0 && player <= 6){
			firedOnBy[player][1]++;
		}else{
			System.err.println("PlayerData::addPlayerHit ->Invalid player.");
			throw new InvalidParameterException();
		}
	}
	
	public void addPlayerShot(int player){
		if(player >= 0 && player <= 6){
			firedOnBy[player][0]++;
		}else{
			System.err.println("PlayerData::addPlayerHit ->Invalid player.");
			throw new InvalidParameterException();
		}
	}
	
	public void addPlayerMiss(int player){
		if(player >= 0 && player <= 6){
			firedOnBy[player][2]++;
		}else{
			System.err.println("PlayerData::addPlayerHit ->Invalid player.");
			throw new InvalidParameterException();
		}
	}

	public void addPlayerAmmo(int player, int ammoType){
		if(player >= 0 && player <= 6){
			switch(ammoType){
				case 0:
					firedOnBy[player][3]++;
					break;
				case 1:
					firedOnBy[player][4]++;
					break;
				case 2:
					firedOnBy[player][5]++;
					break;
			}
		}else{
			System.err.println("PlayerData::addPlayerHit ->Invalid player.");
			throw new InvalidParameterException();
		}
	}
	
	public int getShotsTaken(){
		return tookShots;
	}
	
	public int getRoundsMissed(){
		return roundMissed;
	}
	
	public int getNumHits(){
		return hits;
	}
	
	public int getNumMiss(){
		return misses;
	}
	
	public int getMyID(){
		return myID;
	}
	
	public int[] getAdversaryData(int player){
		int [] temp = new int[6];
		
		if(player < 0 || player > 6){
			System.err.println("PlayerData::getAdversaryData ->Invalid player.");
			throw new InvalidParameterException();
		}else{
		
			for(int i = 0; i < 6; i++){
				temp[i] = firedOnBy[player-1][i];
			}
		}
		
		return temp;
	}
	
	public String toString(){
		String temp = "Player " + myID + " Statistics:\n";
			
				temp+= "    Shots: " + tookShots + " | Hits: " + hits + " | Misses: " + misses + "\n";
				temp+= "    Rounds Missed: " + roundMissed + "\n";
				temp+= "    Other: \n";
			
			for(int i = 0; i < 6; i++){
				temp+= "       Player " + (i+1) + " fired |" + firedOnBy[i][0] + "| Hit me: " 
					+ firedOnBy[i][1] + " | Missed me: " + firedOnBy[i][2] + "\n";
				temp+= "        Ammo fired at me: \n";
				temp+= "            Small: " + firedOnBy[i][3] + " | Med: " + firedOnBy[i][4] + " | Lrg: " + firedOnBy[i][5] + "\n\n";
			}
		
		return temp;
	}
	
	public static void main (String [] args){
		Vector<PlayerData> temp = new Vector<PlayerData>();
		
		for(int i = 0; i < 10; i++){
			temp.add(new PlayerData());
		}
		
		for(int i = 0; i < 10; i++){
			System.out.println(temp.get(i));
		}
	}
}
